package com.zhengqing.demo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * <p>
 * 用户
 * </p>
 *
 * @author zhengqingya
 * @description
 * @date 2021/01/13 10:11
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_user")
@ApiModel("用户")
@EqualsAndHashCode(callSuper = true)
public class User extends Model<User> {

    @ApiModelProperty("主键ID")
    @TableId(type = IdType.AUTO)
    private Long userId;

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("密码")
    private String password;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * sex值为空时，MP更新数据库时不忽略此字段值
     */
    @TableField(value = "sex", updateStrategy = FieldStrategy.IGNORED)
    @ApiModelProperty("性别")
    private Byte sex;

    @ApiModelProperty("备注")
    private String remark;

    @TableField(exist = false)
    @ApiModelProperty(value = "当前页数",  example = "1")
    private Integer page;

    @TableField(exist = false)
    @ApiModelProperty(value = "分页大小",  example = "10")
    private Integer pageSize;

    // 对象和json互相转化的过程当中按照此转化方式转(前后端互相转)
    @JsonFormat(
            pattern = "yyyy-MM-dd",
            timezone = "GMT-8"
    )
   //从requestParam中获取参数并且转化（前端String转化为后端Data）
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField(exist = false)
    private Date startTime;

    // 对象和json互相转化的过程当中按照此转化方式转(前后端互相转)
    @JsonFormat(
            pattern = "yyyy-MM-dd",
            timezone = "GMT-8"
    )
    //从requestParam中获取参数并且转化（前端String转化为后端Data）
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @TableField(exist = false)
    private Date endTime;

}
